﻿using System;
using System.IO;
using System.Net;

namespace ServerIntegration
{
    public abstract class TransferDataBase
    {
        public abstract int GameID { get; }
        public abstract int CharacterID { get; }
        public abstract String ImageURL { get; }
        public abstract String SystemName { get; }

        public abstract String CharacterName { get; }

        public string DownloadImageFromURLToLocal()
        {
            string localFilename = @"PiecePictures\Downloads\" + CharacterName + "GID_" + GameID + "ID_" + CharacterID +
                                   "_web.png";
            if (!File.Exists(localFilename))
            {
                try
                {
                    using (var client = new WebClient())
                    {
                        client.DownloadFile(ImageURL, localFilename);
                    }
                }
                catch (Exception)
                {
                    return string.Empty;
                }
            }
            return Directory.GetCurrentDirectory() + "\\" + localFilename;
        }
    }
}